package com.entity;

import java.util.*;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * SecondCategory entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "second_category", catalog = "dangdang")
public class SecondCategory implements java.io.Serializable {

	// Fields
	private static final long serialVersionUID = 1L;
	private Integer id;
	private FirstCategory firstCategory;
	private String name;
	private List<ThirdCategory> thirdCategories = new ArrayList<ThirdCategory>(0);

	// Constructors

	/** default constructor */
	public SecondCategory() {
	}

	/** minimal constructor */
	public SecondCategory(FirstCategory firstCategory, String name) {
		this.firstCategory = firstCategory;
		this.name = name;
	}

	/** full constructor */
	public SecondCategory(FirstCategory firstCategory, String name,
			List<ThirdCategory> thirdCategories) {
		this.firstCategory = firstCategory;
		this.name = name;
		this.thirdCategories = thirdCategories;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parent_id", nullable = false)
	public FirstCategory getFirstCategory() {
		return this.firstCategory;
	}

	public void setFirstCategory(FirstCategory firstCategory) {
		this.firstCategory = firstCategory;
	}

	@Column(name = "name", nullable = false, length = 200)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "secondCategory")
	public List<ThirdCategory> getThirdCategories() {
		return this.thirdCategories;
	}

	public void setThirdCategories(List<ThirdCategory> thirdCategories) {
		this.thirdCategories = thirdCategories;
	}

}